import { combineReducers } from 'redux';
import types from '../types/homeTypes';
import data from './data.js';



const initState = {
    banners:[
        {img:require('../../images/1.jpg')},
        {img:require('../../images/2.jpg')},
        {img:require('../../images/3.jpg')},
        {img:require('../../images/4.jpg')},
        {img:require('../../images/5.jpg')},
    ],
    business:[
        {logo:"tm", name:"天猫"},
        {logo:"jhs", name:"聚划算"},
        {logo:"tsh", name:"淘生活"},
        {logo:"tdd", name:"淘点点"},
        {logo:"cz", name:"充值"},
        {logo:"qua", name:"去啊"},
        {logo:"ljb", name:"领金币"},
        {logo:"xm", name:"项目"}
    ],
    gifs:data(0,10),
    page:0,
    searchShow:false
};

function todo (state = initState , action) {
    var copyState = Object.assign({},state);
    switch (action.type) {
        case types.GET_GIFS_LIST:
            copyState.page ++ ;
            data(copyState.page,10).map(function(val,index){
                copyState.gifs.push(val);
            });
            return copyState;
        case types.SEARCH_SHOW:
            copyState.searchShow = action.status;
            return copyState;
        default:
            return state;
    }
};

module.exports = combineReducers({todo:todo});